<template>
  <!-- 筛选产品list -->
  <div class="body">
    <datav :data="schemeList"></datav>
  </div>
</template>
<script>
import Header from '@/components/layout/pureHeader'
import singleRing from '@/components/echarts/singleRing'
import datav from '@/components/datav/index.vue'

export default {
  data() {
    return {
      SetFilterList: [], //筛选条件集合
      isMoreCompany: false,
      isShowAllCity: false,
      SearchText: '',
      theModule: '',
      schemeList: [],
      totalCount: 0,
      listPageSize: 20,
      listCurrentPage: 1,
      menuIndex: 5,
      pdfUrl: '',
      DSloution: '',
      solutionList: [],
      BaseLineAndLessonLearnList: [],
      InnovationList: [],
      InnovationTop5List: [],
      SchemeTop5List: [],
      SupplierSolutionTop5List: [],
      JabilComeTop5List: [],
    }
  },
  components: {
    Header,
    singleRing,
    datav,
  },
  watch: {},
  created() {
    if (this.$route.query.index) {
      this.$nextTick(() => {
        this.menuIndex = this.$route.query.index
      })
      console.log('this.menuIndex :>> ', this.menuIndex)
    }
  },
  mounted() {
    this.getAllSchemeInfo()
  },

  methods: {
    delFliter(index) {
      this.SetFilterList.splice(index, 1)
    },
    // 数组对象去重
    deWeight(arr) {
      for (var i = 0; i < arr.length - 1; i++) {
        for (var j = i + 1; j < arr.length; j++) {
          if (arr[i].name == arr[j].name) {
            arr.splice(j, 1)
            //因为数组长度减小1，所以直接 j++ 会漏掉一个元素，所以要 j--
            j--
          }
        }
      }
      return arr
    },

    paginationChange(page, pageSize) {
      console.log(page, pageSize)
      this.listCurrentPage = page
      this.listPageSize = pageSize
      this.getAllSchemeInfo()
    },
    toSchemePage(item) {
      console.log('item :>> ', item)
      let data = JSON.stringify(item)
      //生成pdf 并打开预览
      if (item.PdfFile) {
        window.open(item.PdfFile)
      } else {
        this.$message.warning('PDF is not uploaded for this scenario')
      }
    },
    errorImg(event) {
      this.$pk.errorImg(event)
    },
    SearchBtn(e) {
      // console.log('e :>> ', e)
      this.SearchText = e
      this.getAllSchemeInfo()
    },
    showAllProject(type) {
      if (type === 'company') {
        this.isMoreCompany = !this.isMoreCompany
      } else if (type === 'city') {
        this.isShowAllCity = !this.isShowAllCity
      }
    },
    getSearchInfo(e) {
      // console.log('搜索内容', e)
      if (e) {
        this.SearchText = e[0]
        this.theModule = e[1]
      }
    },
    getAllSchemeInfo() {
      const that = this
      const a = {
        method: 'Statistics_Que',
        userId: window.userId || 1,
        sign: '1',
        currentPage: this.listCurrentPage,
        limit: this.listPageSize,
        language: window.language || 1,
        datas: {},
      }
      this.$post(a).then((result) => {
        console.log('result.data :>> ', result.data)
        this.schemeList = []
        this.solutionList = []
        this.schemeList = result.data
        this.BaseLineAndLessonLearnList = []
        this.$nextTick(() => {
          result.data.forEach((item) => {
            let type = item.ProjectType
            switch (type) {
              case 'Scheme':
                that.schemeList.push(item)
                break
              case 'Solution':
                that.solutionList.push(item)
                break
              case 'BaseLineAndLessonLearn':
                that.BaseLineAndLessonLearnList.push(item)
                break
              case 'Scheme':
                that.schemeList.push(item)

                break
              case 'Innovation':
                that.InnovationList.push(item)

                break
              case 'SchemeTop5':
                that.SchemeTop5List.push(item)

                break
              case 'SupplierSolutionTop5':
                that.SupplierSolutionTop5List.push(item)

                break
              case 'InnovationTop5':
                that.InnovationTop5List.push(item)
                break
              case 'Innovation':
                that.InnovationList.push(item)

                break
              case 'JabilComeTop5':
                that.JabilComeTop5List.push(item)
                break
            }
          })
          this.totalCount = result.count
        })
      })
    },
  },
}
</script>
<style lang="less" scoped>
@import url('css/index.less');
</style>
